<?php
namespace APP\C;

class Index extends Controller
{

    public function indexAction()
    {
        $this->router->redirect('/account/login');
        //$this->view->render('main.tpl');
    }

    public function testAction()
    {
        $this->getDb()->insert('user_info', array('email'=>'test', 'username'=>'测试'));
    }




    /**
     * 分页示例
     */
	public function pagetestAction()
	{
        $perPage = 20;
        $pageRange = 10;

		// 参数
		$page = $this->request->getParam('page', 1);

		// 数据
		$sql = 'SELECT SQL_CALC_FOUND_ROWS * FROM t_note';
		$data = $this->getDb()->fetchAll($sql);
		$sql = 'SELECT FOUND_ROWS()';
		$count = $this->getDb()->fetchOne($sql);
        $count = 100;
		
		// 分页
		$p = new \SF\Paginator($page, $count, $perPage, $pageRange);

		// 模板
		$this->view->page = $p->getRender();
		$this->view->data = $data;
		$this->view->render('test.tpl');
	}
}